Support for the ALTER RESOURCE statement#37392
Merged
Merged
Conversation
terrymanu
requested changes
Dec 15, 2025
Member
terrymanu
left a comment
There was a problem hiding this comment.
Root Cause
- DorisAlterResourceStatement redeclares databaseType, which already exists in the parent SQLStatement, creating duplicate state and potential divergence.
- Assertions only check the resource name and non-null properties, never validating property key/value parsing, so visitor errors can slip through.
- Grammar and visitor accept only string resource names and property keys/values; Doris syntax allows identifier-style keys and values beyond strings (official reference: https://doris.apache.org/docs/2.1/sql-manual/sql-statements/cluster-management/compute-management/ALTER-RESOURCE/).
Analysis
- Redundant field: the parent already holds databaseType; keeping another copy in the subclass risks inconsistency on future changes/serialization.
- Assertion gap: DorisAlterResourceStatementAssert doesn’t verify property key/values, so misparsed or missing properties still pass.
- Syntax/visitor coverage: official syntax shows ALTER RESOURCE '<resource_name>' PROPERTIES(\key
= value, ...), where the key is an identifier (backticked) and the value is not restricted to strings. The current rule using only string_would reject valid statements with unquoted identifiers or non-string values.
Conclusion (Change Request)
- Remove the duplicate databaseType field and assignment in DorisAlterResourceStatement; rely on the parent field. Keep constructor calling super(databaseType) and storing only resourceName and properties:
public final class DorisAlterResourceStatement extends DALStatement {
private final String resourceName;
private final Properties properties;
public DorisAlterResourceStatement(final DatabaseType databaseType, final String resourceName, final Properties properties) {
super(databaseType);
this.resourceName = resourceName;
this.properties = properties;
}
}- Strengthen assertions: add expected property key/values in test cases (e.g., list or map) and validate size plus specific key/values in DorisAlterResourceStatementAssert to ensure visitor parsing is correct.
- Align grammar and visitor with the official doc: allow resource names/property keys as identifiers or strings, and property values as literals (string/number/boolean). Update the visitor to handle IdentifierValue, StringLiteralValue, NumberLiteralValue, and booleans accordingly, and add SQL cases plus assertions covering these forms. After these adjustments, merging will be safer.
Contributor
Author
|
@terrymanu Hi, I have made the revisions as required. Hope you can review them when you have some time. |
terrymanu
requested changes
Dec 16, 2025
Member
terrymanu
left a comment
There was a problem hiding this comment.
Here’s what needs to be fixed before we can merge—thanks for the solid start, please keep going:
- parser/sql/engine/dialect/doris/src/main/java/org/apache/shardingsphere/sql/parser/engine/doris/visitor/statement/type/DorisDALStatementVisitor.java:909: getPropertyValue only handles string/number literals; boolean/NULL/hex/etc. fall through to result.toString(), so
those property values are parsed as object ids, not the literal values. Please decode all LiteralValue types (BooleanLiteralValue, NullLiteralValue, hex/bit, etc.) via getValue(), mirroring other dialect handlers. - Tests: test/it/parser/src/main/resources/case/dal/alter.xml and .../sql/supported/dal/alter.xml only cover string/number properties. Add cases for boolean/NULL (and other literal forms) to exercise the fixed paths.
Once these are addressed, the PR should be in good shape to re-review.
Contributor
Author
|
@terrymanu Hi, Hope you could take a look when you have a moment! |
terrymanu
approved these changes
Dec 16, 2025
Member
terrymanu
left a comment
There was a problem hiding this comment.
Nice work on the comprehensive coverage and tidy wiring—thanks for the thorough contribution!
Contributor
Author
It's my pleasure! |
makssent
pushed a commit
to makssent/shardingsphere
that referenced
this pull request
Apr 9, 2026
…ngsphere/master * remotes/origin/master: Support for the ALTER RESOURCE statement (apache#37392) Update RELEASE-NOTES.md (apache#37400) Add CDCBackendHandlerTest (apache#37399)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
for #31509
Changes proposed in this pull request:
Before committing this PR, I'm sure that I have checked the following options:
./mvnw clean install -B -T1C -Dmaven.javadoc.skip -Dmaven.jacoco.skip -e.